#include<bits/stdc++.h>
#define N 300005
#define M 6000005
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int inf=1e9;
int n,rt,A,B,up[N][20],dep[N];
vector<int>rd[N],d[N];
int f[N],g[N],h[N],dh[N],dhh[N],sz[N],dfn[N],low[N],tt,son[N],len[N],fa[N];
int Mx[N],Mx1[N],mx[N],mx1[N];
void dfs(int u,int f){
	up[u][0]=fa[u]=f,son[u]=-1,d[dep[u]].pb(u),sz[u]=1;
	for(int i=1;(1<<i)<=dep[u];++i)up[u][i]=up[up[u][i-1]][i-1];
	Mx[u]=Mx1[u]=-1;
	for(int v:rd[u]){
		if(v==f)continue;
		dep[v]=dep[u]+1,dfs(v,u),sz[u]+=sz[v],len[u]=max(len[u],len[v]+1);
		if(son[u]==-1||sz[v]>sz[son[u]])son[u]=v;
		if(Mx[u]==-1)Mx[u]=v;else Mx1[u]=v;
	}
}
int top[N];
void dfs1(int u,int g){
	dfn[u]=++tt,top[u]=g;
	if(son[u]!=-1)dfs1(son[u],g);
	for(int v:rd[u])if(!top[v]&&v!=son[u])dfs1(v,v);
	int id=-1,id1=-1;
	for(int v:rd[u]){
		if(dep[v]<dep[u])continue;
		if(id==-1||dhh[id]>=dhh[v])id1=id,id=v;
		else if(id1==-1||dhh[id1]>dhh[v])id1=v;
	}
	for(int v:rd[u]){
		if(dep[v]<dep[u])continue;
		if(id!=v)dh[v]=dhh[id];
		else if(id1!=-1)dh[v]=dhh[id1];
	}
}
int getkth(int u,int k){for(int i=0;(1<<i)<=k;++i)if((k>>i)&1)u=up[u][i];return u;}
int mnv[N<<2];
#define ls (p<<1)
#define rs (p<<1|1)
#define mid (l+r>>1)
void pp(int p){mnv[p]=min(mnv[ls],mnv[rs]);}
void cg(int p,int l,int r,int q,int v){
	if(l==r){mnv[p]=v;return;}
	if(q<=mid)cg(ls,l,mid,q,v);else cg(rs,mid+1,r,q,v);pp(p);
}
int qry(int p,int l,int r,int a,int b){
	int ans=inf;
	if(a<=l&&r<=b)return mnv[p];
	if(a<=mid)ans=min(ans,qry(ls,l,mid,a,b));
	if(b>mid)ans=min(ans,qry(rs,mid+1,r,a,b));
	return ans;
}
int Calc(int x,int lst){
	int ans=0;
	if(Mx[x]!=lst)ans=h[Mx[x]];
	else if(Mx1[x]!=-1)ans=h[Mx1[x]];
	if(ans==0)ans=min(x,dh[lst]);
	return ans;
}
int Qry(int x,int y){
	if(x==y)return inf;
	int ans=inf;
	while(top[x]!=top[y]){
		if(x!=top[x])ans=min(ans,qry(1,1,n,dfn[top[x]],dfn[x]-1));
		ans=min(ans,Calc(fa[top[x]],top[x])),x=fa[top[x]];
	}
	if(x!=y)ans=min(ans,qry(1,1,n,dfn[y],dfn[x]-1));
	return ans;
}
void upd(int p){
	int q=fa[p];
	if(Mx[q]==p);
	else if(Mx1[q]==p){
		if(h[p]>h[Mx[q]])swap(Mx[q],Mx1[q]);
		return;
	}else {
		if(h[p]>=h[Mx[q]])Mx1[q]=Mx[q],Mx[q]=p;
		else if(Mx1[q]==-1||h[p]>=h[Mx1[q]])Mx1[q]=p;
	}
	cg(1,1,n,dfn[q],Calc(q,son[q]));
}
int Fa[N];
int Find(int r){return r==Fa[r]?r:(Fa[r]=Find(Fa[r]));}
int dis[N];
pii ff[M*4],*bit[2][N],*bit1[2][N],*cc=ff;
int upds[N][20],Rt[N][20],Mxd[N],col[2][N][20],bl[N][20],Sz[N],nrt,Mxz[N],vis[N];
void find(int u,int ffa,int cta){
	Sz[u]=1,Mxz[u]=0;
	for(int v:rd[u]){
		if(vis[v]||v==ffa)continue;
		find(v,u,cta),Sz[u]+=Sz[v],Mxz[u]=max(Mxz[u],Sz[v]);
	}Mxz[u]=max(Mxz[u],cta-Sz[u]);
	if(nrt==-1||Mxz[u]<Mxz[nrt])nrt=u;
}
int mxd;
void gd(int u,int ffa,int dn){
	Sz[u]=1,mxd=max(mxd,dis[u]);
	upds[u][dn]=dis[u],Rt[u][dn]=nrt;
	for(int v:rd[u]){
		if(v==ffa||vis[v])continue;
		if(u==nrt)bl[v][dn]=v;
		else bl[v][dn]=bl[u][dn];
		dis[v]=dis[u]+1;
		col[0][v][dn]=col[1][v][dn]=0;
		if(dep[v]>dep[u])col[0][v][dn]=col[0][u][dn];
		else col[1][v][dn]=col[1][u][dn];
		gd(v,u,dn),Sz[u]+=Sz[v];
	}
}
void solve(int u,int G,int dn){
	nrt=-1,find(u,-1,G),u=nrt,mxd=0,vis[u]=1;
	col[0][u][dn]=col[1][u][dn]=1,dis[u]=0,gd(u,-1,dn);
	vector<pii>nxt;for(int v:rd[u])if(!vis[v])nxt.pb(make_pair(v,Sz[v]));
	Mxd[u]=mxd,bit[0][u]=cc,cc+=mxd+1,bit[1][u]=cc,cc+=mxd+1;
	bit1[0][u]=cc,cc+=mxd+1,bit1[1][u]=cc,cc+=mxd+1;
	for(int i=0;i<=mxd;++i)bit[0][u][i]=bit[1][u][i]=make_pair(inf,-2),bit1[0][u][i]=bit1[1][u][i]=make_pair(inf,-1);
	for(auto v:nxt)solve(v.fi,v.se,dn+1);
}
void add(int o,int p,int q,pii v){
	for(int i=q+1;i<=Mxd[p]+1;i+=(i&-i)){
		if(bit[o][p][i-1].se==v.se){
			if(bit[o][p][i-1].fi>=v.fi)bit[o][p][i-1]=v;
		}
		else {
			if(bit[o][p][i-1].fi>=v.fi)bit1[o][p][i-1]=bit[o][p][i-1],bit[o][p][i-1]=v;
			else if(bit1[o][p][i-1].fi>=v.fi)bit1[o][p][i-1]=v;
		}
		assert(bit[o][p][i-1].se!=bit1[o][p][i-1].se);
	}
}
int qry2(int o,int p,int q,int c){
	if(q<0)return inf;q=min(q,Mxd[p]);int ans=inf;
	for(int i=q+1;i;i&=(i-1)){
		if(bit[o][p][i-1].se!=c)ans=min(ans,bit[o][p][i-1].fi);
		if(bit1[o][p][i-1].se!=c)ans=min(ans,bit1[o][p][i-1].fi);
	}
	return ans;
}
void upd1(int p){
	for(int i=0;i<20;++i){
		if(!Rt[p][i])continue;
		add(col[1][p][i],Rt[p][i],upds[p][i],make_pair(f[p],bl[p][i]));
	}
}
int qry1(int p){
	int ans=f[p];
	for(int i=0;i<20;++i){
		if(!Rt[p][i])continue;
		ans=min(ans,qry2(0,Rt[p][i],B-upds[p][i],bl[p][i]));
		if(!col[0][p][i])ans=min(ans,qry2(1,Rt[p][i],B-upds[p][i],bl[p][i]));
	}
	return ans;
}
int main(){
	freopen("nim.in","r",stdin);
	freopen("nim.out","w",stdout);
	ios::sync_with_stdio(0);
	cin>>n>>rt>>A>>B;
	for(int i=1;i<=n;++i)h[i]=0,dh[i]=dhh[i]=inf,Fa[i]=i;
	if(A<=B)cout<<1<<endl,exit(0);
	for(int i=1,a,b;i<n;++i)cin>>a>>b,rd[a].pb(b),rd[b].pb(a);
	dfs(rt,0);
	for(int i=1;i<=n;++i)if(len[i]<A)f[i]=inf;
	for(int i=1;i<=n;++i){
		int x=Find(i);
		while(x&&dep[i]-dep[x]<B)dhh[x]=i,Fa[x]=Find(fa[x]),x=Find(x);
	}
	for(int i=1;i<=n;++i)Fa[i]=i;
	for(int i=1;i<=n;++i){
		int x=Find(i);
		while(x&&dep[i]-dep[x]<=B){
			if(len[x]<A)f[x]=i;
			Fa[x]=Find(fa[x]),x=Find(x);
		}
	}dfs1(rt,rt);
	for(int i=1;i<=n;++i)if(son[i]!=-1)cg(1,1,n,dfn[i],Calc(i,son[i]));
	solve(rt,n,0);
	for(int dd=n;dd>=0;--dd){
		if(dd+A<=n){
			for(int v:d[dd+A]){
				g[v]=min(qry1(v),Qry(v,getkth(v,B)));
				int q=getkth(v,A),p=getkth(v,A-1);
				if(f[q]<g[v])f[q]=g[v];
				if(h[p]<g[v])h[p]=g[v];
			}
		}
		for(int v:d[dd+1])upd(v);
		for(int v:d[dd])upd1(v);
	}cout<<f[rt];
	return 0;
}